﻿namespace STT
{
    using System.Drawing;
    using System.Windows.Forms;

    public class BarreInfo : StatusStrip
    {
        private ToolStripProgressBar ProgressBar;
        private ToolStripStatusLabel InfoLabel;
        // private ToolStripStatusLabel LinkLabel;
        //  private ToolStripStatusLabel LinkLabel2;

        public BarreInfo()
        {
            base.SuspendLayout();
            // this.LinkLabel = new ToolStripStatusLabel();
            // this.LinkLabel.IsLink = true;
            // this.LinkLabel.Name = "toolStripStatusLabel1";
            // this.LinkLabel.Size = new Size(0x88, 0x11);
            // this.LinkLabel.Text = "http://www.syseclabs.com";
            // this.LinkLabel.Click += new EventHandler(this.LinkLabel_Click);
            // this.LinkLabel2 = new ToolStripStatusLabel();
            // this.LinkLabel2.IsLink = true;
            // this.LinkLabel2.Name = "toolStripStatusLabel2";
            // this.LinkLabel2.Size = new Size(140, 0x11);
            // this.LinkLabel2.Text = "http://www.laboskopia.com";
            // this.LinkLabel2.Click += new EventHandler(this.LinkLabel_Click);

            this.ProgressBar = new ToolStripProgressBar();
            this.ProgressBar.Name = "ProgressBar";
            this.ProgressBar.Size = new Size(100, 0x10);
            this.ProgressBar.Minimum = 0;
            this.ProgressBar.Maximum = 0x3e8;
            this.ProgressBar.Value = 0;
            this.ProgressBar.Step = 1;
            this.ProgressBar.Style = ProgressBarStyle.Continuous;
            this.InfoLabel = new ToolStripStatusLabel();
            this.InfoLabel.Name = "InfoLabel";
            this.InfoLabel.Size = new Size(0x13, 0x11);
            this.InfoLabel.Text = " 完成";
            ToolStripItem[] toolStripItems = new ToolStripItem[] { this.ProgressBar, this.InfoLabel };
            this.Items.AddRange(toolStripItems);
            base.Location = new Point(0, 0x1d7);
            base.Name = "StatusStrip";
            base.Size = new Size(0x26a, 0x16);
            base.TabIndex = 0x13;
            this.Text = "StatusStrip";
            base.ResumeLayout(false);
        }

        public void GoWait()
        {
            if (base.FindForm().InvokeRequired)
            {
                base.FindForm().Invoke(new f_void(this.GoWait), null);
            }
            else
            {
                if (this.ProgressBar.Style != ProgressBarStyle.Marquee)
                {
                    this.ProgressBar.Style = ProgressBarStyle.Marquee;
                }
                Program.Fenetre.Cursor = Cursors.WaitCursor;
            }
        }

        // private void LinkLabel_Click(object sender, EventArgs e)
        // {
        //     this.OpenUrl(((ToolStripStatusLabel)sender).Text);
        // }
        //
        // public void OpenUrl(string url)
        // {
        //     new Process { StartInfo = { FileName = url } }.Start();
        // }

        public void Print(string s)
        {
            if (!base.FindForm().InvokeRequired)
            {
                this.InfoLabel.Text = s;
            }
            else
            {
                object[] args = new object[] { s };
                base.FindForm().Invoke(new f_string(this.Print), args);
            }
        }

        public void ResetPrint()
        {
            if (base.FindForm().InvokeRequired)
            {
                base.FindForm().Invoke(new f_void(this.ResetPrint), null);
            }
            else
            {
                this.InfoLabel.Text = " Ok";
            }
        }

        public void StopWait()
        {
            if (base.FindForm().InvokeRequired)
            {
                base.FindForm().Invoke(new f_void(this.StopWait), null);
            }
            else
            {
                if (this.ProgressBar.Style == ProgressBarStyle.Marquee)
                {
                    this.ProgressBar.Style = ProgressBarStyle.Continuous;
                    this.ProgressBar.Value = 0;
                }
                Program.Fenetre.Cursor = Cursors.Default;
            }
        }

        private delegate void f_string(string s);

        private delegate void f_void();
    }
}